n,m=map(int,input().split())
# 初始下标从1开始
a=[[0]*(m+1) for i in range(n+1)]
sum=[[0]*(m+1) for i in range(n+1)]

# 输入一个二维数组
for i in range(1,n+1):
    a[i]=[0]+list(map(int,input().split()))

# 输出打印二维数组
def output(a,n):
    for i in range(1,n+1):
        print(' '.join(map(str,a[i][1:])))

# 构造二维前缀和
def pre_sum(a,sum):
    for i in range(1,1+n):
        for j in range(1,1+m):
            sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+a[i][j]

pre_sum(a,sum)
output(sum,n)

# 计算二维前缀和
def get_sum(sum,x1,y1,x2,y2):
    return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1]

# 注意：sum的坐标是从1开始的
print(get_sum(sum,2,2,3,3))